<!--分享-->
<template>
    <transition name="slide" mode="out-in">
        <div class="share-menu" v-if="isShareMenu">
            <div class="share-qr-code" @click="isShareMenu=false">
                <!--生成二维码的图片，点击分享-->
            </div>
            <div class="share-options">
                <div class="share-div">
                    <img class="share-icon" src="/src/assets/share/wx.jpeg">
                    <span class="close-share" @click="shareToWeChat">微信</span>
                </div>
                <div class="share-div">
                    <img class="share-icon" src="/src/assets/share/wx.jpeg">
                    <span class="close-share" @click="shareToMoments">朋友圈</span>
                </div>
                <div class="share-div">
                    <img class="share-icon" src="/src/assets/share/wx.jpeg">
                    <span class="close-share" @click="shareToQQ">QQ</span>
                </div>
                <div class="share-div">
                    <img class="share-icon" src="/src/assets/share/wx.jpeg">
                    <span class="close-share" @click="shareToWeibo">微博</span>
                </div>
                <div class="share-div" @click="copyLink('http://s')">
                    <img class="share-icon" src="/src/assets/share/wx.jpeg">
                    <span class="close-share">复制链接</span>
                </div>
                <div class="share-div">
                    <img class="share-icon" src="/src/assets/share/wx.jpeg">
                    <span class="close-share">关闭</span>
                </div>
            </div>
        </div>
    </transition>
</template>

<script setup>
import { defineProps, watch, ref } from 'vue';

const props = defineProps({
    isShareMenuVisible: {
        type: Boolean,
        default: false
    }
});

const isShareMenu = ref(false);

watch(() => {
    isShareMenu.value = props.isShareMenuVisible;
});


const shareToWeChat = () => {
  // 分享微信的逻辑
};

const shareToMoments = () => {
  // 分享朋友圈的逻辑
};

const shareToQQ = () => {
  // 分享QQ的逻辑
};

const shareToWeibo = () => {
  // 分享微博的逻辑
};

const copyLink = (url) => {
    navigator.clipboard.writeText(url).then(() => {
        alert('链接已复制！' + url);
    });
};
</script>

<style scoped>
.share-menu {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    transition: bottom 0.3s;
    z-index: 100;
}
.share-qr-code {
    background-color: rgba(0, 0, 0, 0.5);
    width: 100%;
    height: 100%;
    cursor: pointer;
}
.share-options {
    padding-bottom: 10%;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.2);
    transition: transform 0.3s ease;
    z-index: 1001;
    height: 20%;
    display: inline-block;
    text-align: left;
}

.share-options .share-div {
    cursor: pointer;
    height: 72px;
    margin-right: 10px;
    display: inline-block;
}

.share-options .share-icon {
    border-radius: 50%;
    height: 45px;
    width: 45px;
    margin: auto;
    display: block;
}

.share-options .close-share {
    font-size: 14px;
    background-color: transparent;
    padding-top: 0px;
    height: 15px;
    width: 60px;
    display: block;
    margin: auto;
    text-align: center;
    display: block;
    margin: 0 auto;
}

.slide-enter-active, .slide-leave-active {
    transition: transform 0.3s ease;
}

.slide-enter, .slide-leave-to {
    transform: translateY(100%);
}
</style>